<?php

/*
 * 此文件做伪静态使用
 */

class Url_model extends CI_Model {

    public $baseUrl = "";
    //public $isRewrite=true;
    public $isRewrite = FALSE;

    function __construct() {
        parent::__construct();
        $this->baseUrl = WEB_URL;
    }

    /*
     * 新闻详情
     */

    function getNewsDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/news/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=news&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    /*
     * 
     */

    function getNewsIndexUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/news/";
        } else {
            $outUrl = $this->baseUrl . "/?c=news&m=index";
        }
        return $outUrl;
    }

    /*
     * 新闻列表
     */

    function getNewsListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "cat_aid" => 0,
            "cat_bid" => 0,
            "cat_cid" => 0,
            "zhuanti_id" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/news/list-" . $cat_aid . "-" . $cat_bid . "-" . $cat_cid . "-" . $zhuanti_id . "-" . $page . ".html";
        } else {
            $outUrl = $this->baseUrl . "/?c=news&m=lists" . ($cat_aid ? "&cat_aid=" . $cat_aid : "") . ($cat_bid ? "&cat_bid=" . $cat_bid : "") . ($cat_cid ? "&cat_cid=" . $cat_cid : "") . ($zhuanti_id ? "&zhuanti_id=" . $zhuanti_id : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    /*
     * 供应列表参数
     */

    function getGongyingListParamStr() {
        $outArr = array(
            "province_id" => "pr",
            'city_id' => "ct",
            'district_id' => "dt",
            'cat_aid' => "ca",
            'leixing_id' => 'lx',
            'mianji_id' => 'mj',
            'sheng_nianxian_id' => 'sn',
            'order_by' => 'ob',
            "keyword" => "kw", //关键词
        );
        return $outArr;
    }

    /*
     * 供应列表
     */

    function getGongyingListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "province_id" => 0,
            'city_id' => 0,
            'district_id' => 0,
            'cat_aid' => 0,
            'leixing_id' => 0,
            'mianji_id' => 0,
            'sheng_nianxian_id' => 0,
            "keyword" => "", //关键词
            'order_by' => 0,
            "page" => "",
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);

        $paramTagArr = $this->getGongyingListParamStr();

        foreach ($paramTagArr as $k => $v) {
            if ($$k) {
                $paramTagArr[$k] = $v . $$k;
            } else {
                unset($paramTagArr[$k]);
            }
        }
        $paramStr = implode("-", $paramTagArr);

        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/liuzhuan/" . ($paramStr ? "list-" . $paramStr . "/" : "") . ($page ? $page . ".html" : "");
        } else {
            $outUrl = $this->baseUrl . "/?c=gongying&m=lists" . ($paramStr ? "&paramStr=list-" . $paramStr : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    /*
     * 
     */

    function getGongyingDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/liuzhuan/" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=gongying&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    /*
     * 供应列表参数
     */

    function getXuqiuListParamStr() {
        $outArr = array(
            "province_id" => "pr",
            'city_id' => "ct",
            'district_id' => "dt",
            'cat_aid' => "ca",
            'leixing_id' => 'lx',
            'mianji_id' => 'mj',
            'sheng_nianxian_id' => 'sn',
            'order_by' => 'ob',
            "keyword" => "kw", //关键词
        );
        return $outArr;
    }

    /*
     * 供应列表
     */

    function getXuqiuListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "province_id" => 0,
            'city_id' => 0,
            'district_id' => 0,
            'cat_aid' => 0,
            'leixing_id' => 0,
            'mianji_id' => 0,
            'sheng_nianxian_id' => 0,
            "keyword" => "", //关键词
            'order_by' => 0,
            "page" => "",
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);

        $paramTagArr = $this->getXuqiuListParamStr();

        foreach ($paramTagArr as $k => $v) {
            if ($$k) {
                $paramTagArr[$k] = $v . $$k;
            } else {
                unset($paramTagArr[$k]);
            }
        }
        $paramStr = implode("-", $paramTagArr);

        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/xuqiu/" . ($paramStr ? "list-" . $paramStr . "/" : "") . ($page ? $page . ".html" : "");
        } else {
            $outUrl = $this->baseUrl . "/?c=xuqiu&m=lists" . ($paramStr ? "&paramStr=list-" . $paramStr : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    /*
     * 
     */

    function getXuqiuDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/xuqiu/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=xuqiu&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    function getCompanyListParamStr() {
        $outArr = array(
            "province_id" => "pr",
            'city_id' => "ct",
            'district_id' => "dt",
            'order_by' => 'ob',
            "keyword" => "kw", //关键词
        );
        return $outArr;
    }

    /*
     * 服务中心
     */

    function getCompanyListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "province_id" => 0,
            'city_id' => 0,
            'district_id' => 0,
            "keyword" => "", //关键词
            'order_by' => 0,
            "page" => "",
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);

        $paramTagArr = $this->getCompanyListParamStr();

        foreach ($paramTagArr as $k => $v) {
            if ($$k) {
                $paramTagArr[$k] = $v . $$k;
            } else {
                unset($paramTagArr[$k]);
            }
        }
        $paramStr = implode("-", $paramTagArr);

        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/company/" . ($paramStr ? "list-" . $paramStr . "/" : "") . ($page ? $page . ".html" : "");
        } else {
            $outUrl = $this->baseUrl . "/?c=company&m=lists" . ($paramStr ? "&paramStr=list-" . $paramStr : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    /*
     * 公司
     */

    function getCompanyIndexUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "company_id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($company_id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/company/" . $company_id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?d=company&c=index&m=index&company_id=" . $company_id;
            }
        }
        return $outUrl;
    }

    /*
     * 公司新闻列表
     */

    function getCompanyNewsListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "company_id" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($company_id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/shop/" . $company_id . "/news/list-" . $page . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?d=company&c=news&m=lists&company_id=" . $company_id . "&page=" . $page;
            }
        }
        return $outUrl;
    }

    /*
     * 公司新闻详情
     */

    function getCompanyNewsDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "company_id" => 0,
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($company_id && $id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/shop/" . $company_id . "/news/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?d=company&c=news&m=detail&company_id=" . $company_id . "&id=" . $id;
            }
        }
        return $outUrl;
    }
    
    /*
     * 公司经纪人
     */

    function getCompanyJingjirenListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "company_id" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($company_id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/shop/" . $company_id . "/jingjiren/list-" . $page . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?d=company&c=jingjiren&m=lists&company_id=" . $company_id . "&page=" . $page;
            }
        }
        return $outUrl;
    }
    
    /*
     * 公司土地
     */

    function getCompanyGongyingListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "company_id" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($company_id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/shop/" . $company_id . "/gongying/list-" . $page . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?d=company&c=gongying&m=lists&company_id=" . $company_id . "&page=" . $page;
            }
        }
        return $outUrl;
    }

    /*
     * 招商
     */

    function getAskListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "is_jiejue" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/ask/list-" . $is_jiejue . "-" . $page . ".html";
        } else {
            $outUrl = $this->baseUrl . "/?c=ask&m=lists" . ($is_jiejue ? "&is_jiejue=" . $is_jiejue : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    /*
     * 
     */

    function getAskDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/ask/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=ask&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    /*
     * 招商
     */

    function getTiebaListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "is_hot" => 0,
            "is_jinghua" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/tieba/list-" . $is_hot . "-" . $is_jinghua . "-" . $page . ".html";
        } else {
            $outUrl = $this->baseUrl . "/?c=tieba&m=lists" . ($is_hot ? "&is_hot=" . $is_hot : "") . ($is_jinghua ? "&is_jinghua=" . $is_jinghua : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    function getTiebaDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/tieba/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=tieba&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    /*
     * 招商
     */

    function getZhaoshangListUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "yongtu_id" => 0,
            "is_hot" => 0,
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/zhaoshang/list-" . $yongtu_id . "-" . $is_hot . "-" . $page . ".html";
        } else {
            $outUrl = $this->baseUrl . "/?c=zhaoshang&m=lists" . ($yongtu_id ? "&yongtu_id=" . $yongtu_id : "") . ($is_hot ? "&is_hot=" . $is_hot : "") . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

    function getZhaoshangDetailUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "id" => 0,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($id) {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/zhaoshang/detail-" . $id . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?c=zhaoshang&m=detail&id=" . $id;
            }
        }
        return $outUrl;
    }

    /*
     * ajax处理连接
     */

    function getAjaxUrl($paramArr = array()) {
        $outUrl = "";

        $optionArr = array(
            "d" => "", //文件夹
            "c" => "", //控制器
            "m" => "", //方法名
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($c != "" && $m != "") {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/ajax" . ($d != "" ? "D" : "") . "/" . ($d != "" ? $d . "-" : "") . $c . "-" . $m . ".html";
            } else {
                $outUrl = $this->baseUrl . "/?" . ($d != "" ? "d=" . $d : "") . "&c=" . $c . "&m=" . $m;
            }
        }
        return $outUrl;
    }

    /*
     *
     */

    function getDefaultUrl($paramArr = array()) {
        $outUrl = "";

        $optionArr = array(
            "c" => "", //控制器
            "m" => "", //方法名
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($c != "" || $m != "") {
            if ($isRewrite) {
                $outUrl = $this->baseUrl . "/" . ($c ? $c . "/" : "") . ($m ? $m . "/" : "");
            } else {
                $outUrl = $this->baseUrl . "/" . ($c ? "?c=" . $c : "") . ($m ? "&m=" . $m : "");
            }
        }
        return $outUrl;
    }

    /*
     * 新闻列表
     */

    function getNewsZhuantiUrl($paramArr = array()) {

        $outUrl = "";

        $optionArr = array(
            "page" => 1,
            "isRewrite" => $this->isRewrite,
        );
        if (!empty($paramArr)) {
            $optionArr = array_merge($optionArr, $paramArr);
        }
        extract($optionArr);
        if ($isRewrite) {
            $outUrl = $this->baseUrl . "/news/zhuanti/" . $page . ".html";
        } else {
            $outUrl = $this->baseUrl . "/?c=news&m=zhuanti" . ($page ? "&page=" . $page : "");
        }
        return $outUrl;
    }

}
